function takepicture()
{
	alert("ok");
    
} 
   /*
        */
        function init(t){
            accessLocalWebCam("camera_box");
        }
         
        // Normalizes window.URL
        window.URL = window.URL || window.webkitURL || window.msURL || window.oURL;
        // Normalizes navigator.getUserMedia
    
     navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia|| navigator.mozGetUserMedia || navigator.msGetUserMedia;
 
        function isChromiumVersionLower() {
          var ua = navigator.userAgent;
          var testChromium = ua.match(/AppleWebKit\/.* Chrome\/([\d.]+).* Safari\//);
          return (testChromium && (parseInt(testChromium[1].split('.')[0]) < 19));
        }
 
         
        function successsCallback(stream) {
            document.getElementById('camera_errbox').style.display = 'none';
 
      		alert("successsCallback");
         document.getElementById('camera_box').src = (window.URL && window.URL.createObjectURL) ? 
window.URL.createObjectURL(stream) : stream;
         
			alert(document.getElementById('camera_box').src);
         
        }
         
        function errorCallback(err) {
            alert(err);
        }
         
        function accessLocalWebCam(id) {
          try {
            // Tries it with spec syntax
            if(navigator.getUserMedia){
                 alert("support");
                navigator.getUserMedia({ video: true }, successsCallback, errorCallback);
            }else{
                alert("no support");
            }


             var canvas = document.getElementById("canvas"),
                    context = canvas.getContext("2d"),
                    video = document.getElementById('camera_box');

            
            document.getElementById("snap").addEventListener("click", function() {  
                context.drawImage(video, 0, 0, 640, 480);
            }); 

            setTimeout("document.getElementById('snap').click()",1000); 
          } catch (err) {
            // Tries it with old spec of string syntax
            navigator.getUserMedia('video', successsCallback, errorCallback);
          }
        }
         